package com.zhengshang.api.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.zhengshang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhengshang.api.mapper.AppActivityMapper;
import com.zhengshang.api.domain.AppActivity;
import com.zhengshang.api.service.IAppActivityService;

/**
 * APP活动Service业务层处理
 * 
 * @author zhengshang
 * @date 2021-04-05
 */
@Service
public class AppActivityServiceImpl implements IAppActivityService 
{
    @Autowired
    private AppActivityMapper appActivityMapper;

    /**
     * 查询APP活动
     * 
     * @param activityId APP活动ID
     * @return APP活动
     */
    @Override
    public AppActivity selectAppActivityById(Long activityId)
    {
        return appActivityMapper.selectAppActivityById(activityId);
    }

    /**
     * 查询APP活动列表
     * 
     * @param appActivity APP活动
     * @return APP活动
     */
    @Override
    public List<AppActivity> selectAppActivityList(AppActivity appActivity)
    {
        return appActivityMapper.selectAppActivityList(appActivity);
    }

    @Override
    public List<AppActivity> selectWaitStartList(AppActivity appActivity) {
        List<AppActivity> appActivityList = appActivityMapper.selectWaitStartList(appActivity);
        return appActivityList == null ? new ArrayList<>() : appActivityList;
    }

    @Override
    public List<AppActivity> queryList(AppActivity appActivity) {
        List<AppActivity> appActivityList = appActivityMapper.queryList(appActivity);
        return appActivityList == null ? new ArrayList<>() : appActivityList;
    }

    /**
     * 新增APP活动
     * 
     * @param appActivity APP活动
     * @return 结果
     */
    @Override
    public int insertAppActivity(AppActivity appActivity)
    {
        appActivity.setCreateTime(DateUtils.getNowDate());
        return appActivityMapper.insertAppActivity(appActivity);
    }

    /**
     * 修改APP活动
     * 
     * @param appActivity APP活动
     * @return 结果
     */
    @Override
    public int updateAppActivity(AppActivity appActivity)
    {
        appActivity.setUpdateTime(DateUtils.getNowDate());
        return appActivityMapper.updateAppActivity(appActivity);
    }

    @Override
    public int updateState(AppActivity appActivity) {
        appActivity.setUpdateTime(DateUtils.getNowDate());
        return appActivityMapper.updateState(appActivity);
    }

    /**
     * 批量删除APP活动
     * 
     * @param activityIds 需要删除的APP活动ID
     * @return 结果
     */
    @Override
    public int deleteAppActivityByIds(Long[] activityIds)
    {
        return appActivityMapper.deleteAppActivityByIds(activityIds);
    }

    /**
     * 删除APP活动信息
     * 
     * @param activityId APP活动ID
     * @return 结果
     */
    @Override
    public int deleteAppActivityById(Long activityId)
    {
        return appActivityMapper.deleteAppActivityById(activityId);
    }
}
